#ifndef COMMON_H
#define COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include "define.h"

extern int total_time;
extern int cmd_committed;
int current_instruction;

int file_length(FILE *f); //returns file size in bytes
int isNumeric(char * argument, int * number, int negativeAllowed); //returns "1" if string represent a number, "0" otherwise
char *trimwhitespace(char *str); //returns a new string that equals given string but without whitespaces
void strip_newline(char *str, int size); //removes '\n' character from the end of the string
int findMemberIndex(char * text, char ** arr, int arr_size); //returned index of given string in given array of strings, -1 if not found.
int iLog2 (int val);
void printBuffer(FILE * target, unsigned char * data, int size);
void printBuffer2(FILE * target, unsigned char data[], int size);

enum CONFIG_VALUES_ENUM {ADDSUB_DELAY,
	  MULDIV_DELAY,
	  INSTRUCTION_Q_DEPTH,
	  ADDSUB_RS,
	  MULDIV_RS,
	  LOAD_Q_DEPTH,
	  STORE_Q_DEPTH,
	  REORDER_BUFFER,
	  GHR_WIDTH,
	  TWO_THREADS_ENABLED,
	  L1_BLOCK_SIZE,
	  L1_ACCESS_DELAY,
	  L1_CACHE_SIZE,
	  L2_BLOCK_SIZE,
	  L2_ACCESS_DELAY,
	  L2_CACHE_SIZE,
	  MEM_ACCESS_DELAY};

typedef struct {
	char command_str[MAX_CMD_LINE_LENGTH];
	char * instruction;
	char ** argv;
	int argc;
	int inst_num;
	int rd;
	int rs;
	int rt;
	int imm;
	int offset;
	char label[MAX_LABEL_LENGTH];
} Command;

#endif